package com.starblink.android.basic.network.interceptor

import com.apollographql.apollo3.api.http.HttpRequest
import com.apollographql.apollo3.api.http.HttpResponse
import com.apollographql.apollo3.network.http.HttpInterceptor
import com.apollographql.apollo3.network.http.HttpInterceptorChain
import okio.Buffer

/**
 *  Create by yuanl at 2023/4/17
 **/
class ApolloHttpInterceptor : HttpInterceptor {


    override suspend fun intercept(
        request: HttpRequest,
        chain: HttpInterceptorChain
    ): HttpResponse {
        /*val buffer = Buffer()
        request.body?.writeTo(buffer)
        val bodyByteString = buffer.readByteString().utf8()
        val path = if (bodyByteString.isNotEmpty()) {
            val start = bodyByteString.indexOf("\"operationName\":\"")
            val end = bodyByteString.indexOf("")
            "/${bodyByteString.substring(start, end)}"
        } else ""
        return chain.proceed(
            request.newBuilder(
                request.method,
                request.url + path
            ).apply {
                if (request.body != null) {
                    body(request.body!!)
                }
            }.build()
        )*/
        return chain.proceed(request)
    }


}